package adv8;

import java.lang.reflect.Method;

public class CalcTest {

	public static void main(String[] args) throws Exception, SecurityException {
		Calc c = new Calc();
		// 注解的效果看不到
		// int r = c.add(4, 10);
		// System.out.println(r);
		Method m = c.getClass().getDeclaredMethod("takeawy", int.class,
				int.class);
		if (m.isAnnotationPresent(MyTest.class)) {
			// 有
			MyTest my = m.getAnnotation(MyTest.class);
			System.out.println(my.before());
			Object r = m.invoke(c, 30, 40);
			System.out.println("结果是" + r);
			System.out.println(my.after());
		} else {
			Object r = m.invoke(c, 30, 40);
			System.out.println("结果是" + r);
		}
	}
}
